Skip to content

Conversation

Hassnaa9
Copy link

@Hassnaa9 Hassnaa9 commented Aug 1, 2025

Fixes #12248

This pull request updates the Launch a flavor section of the Android flavors documentation to correct the command for building a specific flavor.

Preview:
https://flutter-docs-prod--pr12257-fix-android-flavors-command-rj9gzarb.web.app/deployment/flavors

The Problem:
The current documentation at src/content/deployment/flavors.md incorrectly states that the flutter build command can be used with only the --flavor flag. As of recent Flutter updates, this syntax is invalid and results in an error... (and so on)

@Hassnaa9 Hassnaa9 requested review from sfshaza2, parlough, jmagman and a team as code owners August 1, 2025 09:03
@Hassnaa9
Copy link
Author

@Sfshaza @parlough @jmagman can you review this pr , thanks !

@parlough
Copy link
Member

/gcbrun

@flutter-website-bot
Copy link
Collaborator

Visit the preview URL for this PR (updated for commit 3165433):

https://flutter-docs-prod--pr12257-fix-android-flavors-command-rj9gzarb.web.app

@parlough
Copy link
Member

parlough commented Aug 29, 2025

Sorry about the delay on reviewing this @Hassnaa9! Thanks again for this fix :)

@antfitch Since you recently overhauled this doc, would you be able to review this PR? Thanks :>

@parlough parlough requested a review from antfitch August 29, 2025 01:16
@antfitch antfitch requested a review from reidbaker August 29, 2025 20:41
@antfitch
Copy link
Contributor

@reidbaker, can you please review this? It looks like there has been a technical change and the command we are using in the original documentation for Android Flavors no longer works as expected.

@Hassnaa9
Copy link
Author

Hassnaa9 commented Sep 3, 2025

@reidbaker @antfitch Could you please review this when you have time?

@antfitch
Copy link
Contributor

antfitch commented Sep 3, 2025

@Hassnaa9 still researching over here! I hope to have confirmation that this is not a code bug by Friday.

@reidbaker reidbaker requested a review from mboetger September 3, 2025 20:40
@reidbaker
Copy link
Contributor

@mboetger can you take a look since I am out sick

Copy link

@mboetger mboetger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing this to our attention! I added a few comments.

Comment on lines +158 to +171
- **To build a release version for a specific flavor:**
```console title="console"
$ flutter build --flavor <flavor_name> --target <path_to_main.dart_file>
```
Example (assuming your `staging` flavor has a `main_staging.dart` entry point):
```console title="console"
$ flutter build apk --release --flavor staging -t lib/main_staging.dart
```
or to build an app bundle:
```console title="console"
$ flutter build appbundle --release --flavor staging -t lib/main_staging.dart
```

```console title="console"
$ flutter run --flavor staging
```
The `--target` flag is used to specify the entry point file for the flavor.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tutorial does not talk at all about creating different target dart files - so I think it's confusing to add the extra detail about the targets. Can we just focus updating the flutter build documentation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hassnaa9 let's revert this change. Can you take a look at @mboetger's last comment?

Example:
- **To build a release version for a specific flavor:**
```console title="console"
$ flutter build --flavor <flavor_name> --target <path_to_main.dart_file>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still doesn't have apk or appbundle so this would fail

Example:
```console title="console"
$ flutter run --flavor staging
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should try to make the changes as minimal as possible to fix the issue, something like this would work:

  1. In the console, navigate to the flavors_example
    directory and enter the following command:

    $ flutter (run | build <subcomand>) --flavor <flavor_name>
    • (run | build <subcommand>): Replace this with one of the
      following:
      • run: Run the app in debug mode.
      • build: Build either an apk or an appbundle.
        • <subcommand>: Either apk or appbundle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on board with this more subtle change as well.

@mboetger
Copy link

mboetger commented Sep 3, 2025

@Hassnaa9 still researching over here! I hope to have confirmation that this is not a code bug by Friday.

@antfitch - As far as I can tell, this is not a bug - the flutter build command has needed a subcommand for some time now. I think it makes sense to update the documentation to reflect that it should be flutter build apk --flavor staging instead of just flutter build --flavor staging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flutter build --flavor does not work
6 participants